const jwt = require('./server/node_modules/jsonwebtoken');

// 使用与服务器相同的密钥
const secret = '159680';

// 创建测试用户的payload
const payload = {
    userId: 'test_user_001',
    phone: '13800138000',
    iat: Math.floor(Date.now() / 1000),
    exp: Math.floor(Date.now() / 1000) + (7 * 24 * 60 * 60) // 7天后过期
};

// 生成token
const token = jwt.sign(payload, secret);

console.log('生成的JWT Token:');
console.log(token);

// 验证token
try {
    const decoded = jwt.verify(token, secret);
    console.log('\n验证成功，解码后的payload:');
    console.log(JSON.stringify(decoded, null, 2));
} catch (error) {
    console.error('Token验证失败:', error.message);
} 